package com.da.alipay.util;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.da.alipay.bean.AlipayCommon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author JokerDa.
 * @date 2021/1/27 10:49
 * Description:
 */
@Component
public class PayClientUtil2 {
    @Autowired
    private AlipayCommon alipayCommon;

    public AlipayClient getDefaultClient() {
        // 1、获得初始化的AlipayClient
        String serverUrl = alipayCommon.getGatewayUrl();
        String appId = alipayCommon.getAppId();
        String privateKey = alipayCommon.getPrivateKey();
        String format = "json";
        String charset = alipayCommon.getCharset();
        String alipayPublicKey = alipayCommon.getPublicKey();
        String signType = alipayCommon.getSignType();
        return new DefaultAlipayClient(serverUrl, appId, privateKey, format, charset,
            alipayPublicKey, signType);
    }
}
